package com.aliyun.messagemgt.common.enums;

import com.google.common.collect.Lists;
import lombok.Getter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: ChannelTypeEnum
 * @Description:
 * @Author: wugongzi
 * @Date: 2021/8/30 12:21
 * @Version: 1.0
 */
@Getter
public enum ChannelTypeEnum {
    /**
     * 微信
     */
    WEIXIN_CHANMEL(1, "微信渠道"),
    /**
     * 蓝信
     */
    LANXIN(2, "蓝信渠道"),


    LANXIN_PLUS(3, "蓝信+渠道"),

    /**
     * 短信渠道
     */
    DYSMS(4, "短信渠道"),
    /**
     * 系统
     */
    SYSTEM(6, "应用端"),
    /**
     * 钉钉
     */
    DING_TALK(7, "钉钉工作通知"),
    /**
     * 支付宝小程序
     */
    ALIPAY_APPLET(8, "支付宝小程序"),
    /**
     * 微信小程序
     */
    WECHAT_APPLET(9, "微信小程序"),
    /**
     * 邮件
     */
    MAIL(10, "邮件"),
    /**
     * 钉钉
     */
    DING_ROBOT(11, "钉钉机器人"),
    /**
     * 钉钉
     */
    DING_COMPANY_GROUP(12, "钉钉企业群"),
    /**
     * 新短信渠道
     */
    NEW_SMS_CHANNEL(13, "新短信渠道"),
    /**
     * 移动开发mPaaS
     */
    MPAAS(20, "移动开发mPaaS");

    private Integer type;
    private String name;


    ChannelTypeEnum(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    /**
     * 获取状态说明
     *
     * @param type 键
     * @return
     */
    public static String getName(int type) {
        ChannelTypeEnum channelType = null;
        for (ChannelTypeEnum channelTypeEnum : ChannelTypeEnum.values()) {
            if (channelTypeEnum.type == (type)) {
                channelType = channelTypeEnum;
            }
        }
        if (channelType == null) {
            return null;
        }
        return channelType.getName();
    }

    /**
     * 获取状态对象实例
     *
     * @param type 键
     * @return
     */
    public static ChannelTypeEnum valueofType(int type) {
        for (ChannelTypeEnum auditEnum : ChannelTypeEnum.values()) {
            if (auditEnum.type == (type)) {
                return auditEnum;
            }
        }
        return null;
    }

    public static List toList() {
        List list = Lists.newArrayList();
        for (ChannelTypeEnum pushChannelEnum : ChannelTypeEnum.values()) {
            Map<String, Object> map = new HashMap<>();
            map.put("type", pushChannelEnum.getType());
            map.put("name", pushChannelEnum.getName());
            list.add(map);
        }
        return list;
    }
}
